﻿
using System;

namespace Medianamik.UI.Web.Shop.Data
{
    public static class Extensions
    {
        public static string ToMoney(this double source)
        {
            return string.Format("{0:c}", source);
        }

        public static string ToMoney(this double? source)
        {
            return source.GetValueOrDefault(0).ToMoney();
        }

        public static string ToMoney(this int source)
        {
            return string.Format("{0:c}", source);
        }

        public static string ToMoney(this decimal source)
        {
            return string.Format("{0:c}", source);
        }

        public static string ToMoney(this object source)
        {
            return string.Format("{0:c}", source);
        }

        public static string ToBillDate(this DateTime? date)
        {
            return string.Format("{0:G}", date.GetValueOrDefault());
        }

        public static string GetAddress(this Address address)
        {
            return address.AddressOne.CompleteAddress(address.AddressTwo);
        }

        public static string CompleteAddress(this string addressOne, string addressTwo)
        {
            return addressOne + ((!string.IsNullOrEmpty(addressTwo)) ? " " + addressTwo : "");
        }
    }
}
